import time

from selenium import webdriver
from selenium.webdriver.common.by import By
#
# def test_01():
#创建浏览器驱动对象
driver=webdriver.Edge()
#你要测试的网址
driver.get("http://localhost/index.php")
#打开浏览器后先窗口最大化
driver.maximize_window()
#1.使用xpath定位定位tpshop首页登陆超链接，并执行点击
driver.find_element(By.CSS_SELECTOR,".red").click()
#2.使用id定位定位登陆页面用户名输入框输入用户名
driver.find_element(By.CSS_SELECTOR,"#username").send_keys("12522963990")
#3.使用name定位定位登陆页面密码输入框,输入密码
driver.find_element(By.CSS_SELECTOR,"#password").send_keys("123456")
#4.使用name定位定位登陆页面验证码输入框,输入验证码
driver.find_element(By.CSS_SELECTOR,"#verify_code").send_keys("8888")
#5.使用xpath定位登陆按钮执行点击,强制等待5s
driver.find_element(By.CSS_SELECTOR,"a[name='sbtbutton']").click()
# time.sleep(2)
# alert=driver.switch_to.alert
time.sleep(5)
driver.find_element(By.CSS_SELECTOR,".layui-layer-btn0").click()
# alert.dismiss()

time.sleep(5)
#浏览器驱动对象进行关闭
driver.quit()


